package com.bw.net.netutils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetUtils {
    private static NetUtils netUtils = null;
    private Boolean flage = true;
    private NetUtils(){}

    public static NetUtils getInstance() {
        if (netUtils==null){
            synchronized (NetUtils.class){
                if (netUtils==null){
                    netUtils=new NetUtils();
                }
            }
        }
        return netUtils;
    }

    public Boolean HaneNet(Context context){
        ConnectivityManager  connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo!=null&&activeNetworkInfo.isConnected()){
            return true;
        }else {
            return false;
        }
    }



    public Boolean IsNet(Context context){
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo!=null&&activeNetworkInfo.isConnected()){
            return true;
        }else {
            return false;
        }
    }
}
